package com.muyu.danmo.domain.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

/**
 * @author Administrator
 */

@Getter
public enum Positions {
    MEMBER("会员",1),
    GOVERNING("理事",2);


    Positions(String name, int code) {
        this.name = name;
        this.code = code;
    }

    private final String name;

    @JsonValue
    @EnumValue
    private final int code;

    @JsonCreator
    public static Positions getByCode(int code) {
        for (Positions positions : values()) {
            if (positions.getCode() == code) {
                return positions;
            }
        }
        return null;
    }
}
